function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

function t(e, t, n) {
    return t in e ? Object.defineProperty(e, t, {
        value: n,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = n, e;
}

function n(e) {
    for (var t = [], n = 0; n < e; n++) t[n] = n + 1;
    return t;
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
    return typeof e;
} : function(e) {
    return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
}, r = e(require("../../utils/util")), a = e(require("../component"));

exports.default = {
    setDefaults: function() {
        return {
            prev_text: "上一页",
            next_text: "下一页",
            page: 0,
            sum: 1,
            pageRange: null
        };
    },
    init: function(e) {
        var u = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, l = r.default.extend(this.setDefaults(), u), i = l.scope || "wx.pages";
        l.page = 0 === l.page ? 0 : l.page - 1, l.pageRange = n(l.sum);
        var p = function(n) {
            l.page = n, e.setData(t({}, i + ".page", n)), c(), "function" == typeof l.pageChange && l.pageChange(n);
        }, c = function() {
            var e = l.scrollTop, t = void 0 === e ? "undefined" : o(e);
            if (wx.pageScrollTo) if ("number" === t) wx.pageScrollTo({
                scrollTop: e
            }); else if ("string" === t) {
                var n = wx.createSelectorQuery();
                n.select(e).boundingClientRect(), n.selectViewport().scrollOffset(), n.exec(function(e) {
                    wx.pageScrollTo({
                        scrollTop: e[0].top
                    });
                });
            }
        };
        return new a.default(e, {
            scope: i,
            data: l,
            methods: {
                onPrevTap: function(e) {
                    var t = l.page - 1;
                    t < 0 || p(t);
                },
                pageNumChange: function(e) {
                    var t = parseInt(e.detail.value, 10);
                    p(t);
                },
                onNextTap: function(e) {
                    var t = l.page + 1;
                    t >= l.sum || p(t);
                }
            }
        });
    }
};